package com.wang.lottery.domain.activity.service.stateflow.impl;

import com.wang.lottery.common.Constants;
import com.wang.lottery.common.Result;
import com.wang.lottery.domain.activity.service.stateflow.IStateHandler;
import com.wang.lottery.domain.activity.service.stateflow.StateConfig;
import org.springframework.stereotype.Service;

/**
 * @author wjh
 * @create 2023-11-04 20:24
 * 状态处理服务
 */
@Service
public class StateHandlerImpl extends StateConfig implements IStateHandler {
    /**
     * 编辑
     *
     * @param activityId 活动id
     * @param stateId    当前状态
     * @return 审核结果
     */
    @Override
    public Result edit(Long activityId, Constants.ActivityState stateId) {
        return super.stateHandlerMap.get(stateId.getCode()).edit(activityId,stateId);
    }

    /**
     * 提审
     *
     * @param activityId 活动id
     * @param stateId    当前状态
     * @return 审核结果
     */
    @Override
    public Result arraignment(Long activityId, Constants.ActivityState stateId) {
        return super.stateHandlerMap.get(stateId.getCode()).arraignment(activityId,stateId);
    }

    /**
     * 审核通过
     *
     * @param activityId 活动id
     * @param stateId    当前状态
     * @return 审核结果
     */
    @Override
    public Result checkPass(Long activityId, Constants.ActivityState stateId) {
        return super.stateHandlerMap.get(stateId.getCode()).checkPass(activityId,stateId);
    }

    /**
     * 审核拒绝
     *
     * @param activityId 活动id
     * @param stateId    当前状态
     * @return 审核结果
     */
    @Override
    public Result checkRefuse(Long activityId, Constants.ActivityState stateId) {
        return super.stateHandlerMap.get(stateId.getCode()).checkRefuse(activityId,stateId);
    }

    /**
     * 撤销审核
     *
     * @param activityId 活动id
     * @param stateId    当前状态
     * @return 审核结果
     */
    @Override
    public Result checkRevoke(Long activityId, Constants.ActivityState stateId) {
        return super.stateHandlerMap.get(stateId.getCode()).checkRevoke(activityId,stateId);
    }

    /**
     * 关闭
     *
     * @param activityId 活动id
     * @param stateId    当前状态
     * @return 审核结果
     */
    @Override
    public Result close(Long activityId, Constants.ActivityState stateId) {
        return super.stateHandlerMap.get(stateId.getCode()).close(activityId,stateId);
    }

    /**
     * 开启
     *
     * @param activityId 活动id
     * @param stateId    当前状态
     * @return 审核结果
     */
    @Override
    public Result open(Long activityId, Constants.ActivityState stateId) {
        return super.stateHandlerMap.get(stateId.getCode()).open(activityId,stateId);
    }

    /**
     * 运行活动中
     *
     * @param activityId 活动id
     * @param stateId    当前状态
     * @return 审核结果
     */
    @Override
    public Result doing(Long activityId, Constants.ActivityState stateId) {
        return super.stateHandlerMap.get(stateId.getCode()).doing(activityId,stateId);
    }
}
